﻿@inherits BaseComponent

<ul class="kui-app-menu">
    @if (MenuItems != null && MenuItems.Count > 0)
    {
        foreach (var item in MenuItems)
        {
            if (!CheckItem(item))
                continue;

            @RenderItem(item)
        }
    }
    @if (ShowPending)
    {
        @RenderItem(new MenuInfo { Name = Language.FuncPending, Icon = "plus", Color = "#4fa624" })
    }
</ul>

@code {
    RenderFragment RenderItem(MenuInfo item) => @<li @onclick="e=>OnItemClick(item)" style="@Width">
        @if (item.Badge > 0)
        {
            <Badge Count="item.Badge">
                <div class="kui-app-menu-icon" style="background-color:@item.Color">
                    <Icon Type="@item.Icon" Theme="IconThemeType.Outline" />
                </div>
            </Badge>
        }
        else
        {
            <div class="kui-app-menu-icon" style="background-color:@item.Color">
                <Icon Type="@item.Icon" Theme="IconThemeType.Outline" />
            </div>
        }
        <div>@Language.GetString(item)</div>
    </li>;
}